package c.h.a.k0.a;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import c.h.a.m0.o;
import com.liuzh.deviceinfo.tests.TestesActivity;

/* compiled from: WifiTestFragment */
public class i0 extends c.h.a.y.a {
    public ImageView W;
    public TextView X;
    public Button Y;
    public WifiManager Z;
    public int b0 = 2;
    public TestesActivity c0;
    public View d0;
    public BroadcastReceiver e0 = new b();

    /* compiled from: WifiTestFragment */
    public class a extends Thread {
        public void run() {
            if (i0.this.Z.isWifiEnabled()) {
                i0.this.Z.setWifiEnabled(false);
            } else {
                i0.this.Z.setWifiEnabled(true);
            }
            c.h.a.m0.p.a.b(new w(this));
            try {
                Thread.sleep(2000);
            } catch (InterruptedException unused) {
            }
            if (!i0.this.m0()) {
                i0 i0Var;
                if (i0.this.Z.isWifiEnabled()) {
                    i0Var = i0.this;
                    i0Var.b0 = 1;
                    i0Var.Z.setWifiEnabled(false);
                } else {
                    i0Var = i0.this;
                    i0Var.b0 = 0;
                    i0Var.Z.setWifiEnabled(true);
                }
            }
        }
    }

    /* compiled from: WifiTestFragment */
    public class b extends BroadcastReceiver {
        public void onReceive(Context context, Intent intent) {
            int intExtra = intent.getIntExtra("wifi_state", 4);
            i0 i0Var;
            if (intExtra == 0) {
                i0.this.W.setImageResource(2131231128);
                i0.this.Y.setVisibility(8);
            } else if (intExtra == 1) {
                i0Var = i0.this;
                if (i0Var.b0 == 1) {
                    i0Var.W.setImageResource(2131231130);
                    i0.this.X.setText(2131690450);
                    i0.this.Y.setVisibility(0);
                    o.b.b(1);
                    return;
                }
                i0Var.W.setImageResource(2131231128);
                i0.this.Y.setVisibility(8);
            } else if (intExtra == 2) {
                i0.this.W.setImageResource(2131231128);
                i0.this.Y.setVisibility(8);
                i0.this.X.setText(2131690570);
            } else if (intExtra == 3) {
                i0Var = i0.this;
                if (i0Var.b0 == 0) {
                    i0Var.W.setImageResource(2131231130);
                    i0.this.X.setText(2131690450);
                    i0.this.Y.setVisibility(0);
                    o.b.b(1);
                    return;
                }
                i0Var.W.setImageResource(2131231128);
                i0.this.Y.setVisibility(8);
            } else if (intExtra == 4) {
                i0.this.W.setImageResource(2131231129);
                i0.this.Y.setVisibility(8);
                i0.this.X.setText(2131690449);
                o.b.b(0);
            }
        }
    }

    public void D(Context context) {
        super.D(context);
        TestesActivity testesActivity = (TestesActivity) context;
        this.c0 = testesActivity;
        testesActivity.setTitle(2131690569);
    }

    public void E(Bundle bundle) {
        super.E(bundle);
        this.c0.registerReceiver(this.e0, new IntentFilter("android.net.wifi.WIFI_STATE_CHANGED"));
    }

    public View G(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        if (this.d0 == null) {
            View inflate = layoutInflater.inflate(2131493071, viewGroup, false);
            this.d0 = inflate;
            ImageView imageView = (ImageView) inflate.findViewById(2131296633);
            this.W = imageView;
            imageView.setImageResource(2131231128);
            this.X = (TextView) this.d0.findViewById(2131296715);
            this.Y = (Button) this.d0.findViewById(2131296405);
            WifiManager wifiManager = (WifiManager) this.c0.getApplicationContext().getSystemService("wifi");
            this.Z = wifiManager;
            if (wifiManager == null) {
                this.W.setImageResource(2131231129);
                this.X.setText(2131690449);
                o.b.b(0);
                return this.d0;
            }
            new a().start();
            this.Y.setOnClickListener(new x(this));
        }
        return this.d0;
    }

    public void H() {
        this.E = true;
        if (this.Z != null) {
            BroadcastReceiver broadcastReceiver = this.e0;
            if (broadcastReceiver != null) {
                this.c0.unregisterReceiver(broadcastReceiver);
            }
        }
    }
}
